import request from '@/config/axios'

export interface WaybillVO {
  id: number
  waybillNo: string
  waybillSource: number
  planNo: string
  planType: boolean
  customerId: number
  customerName: string
  coalType: number
  loadingSiteId: number
  loadingSiteName: string
  vehicleNo: string
  driverId: number
  driverName: string
  driverMobile: string
  driverIdNo: string
  loadingWeighbridge: string
  loadingNetWeight: string
  loadingCompleteTime: Date
  waybillStatus: string
}

// 查询运单管理列表
export const getWaybillPage = async (params: WaybillPageReqVO) => {
  return await request.get({ url: `/queue/waybill/page`, params })
}

// 查询运单管理详情
export const getWaybill = async (id: number) => {
  return await request.get({ url: `/queue/waybill/get?id=` + id })
}

// 新增运单管理
export const createWaybill = async (data: WaybillVO) => {
  return await request.post({ url: `/queue/waybill/create`, data })
}

// 修改运单管理
export const updateWaybill = async (data: WaybillVO) => {
  return await request.put({ url: `/queue/waybill/update`, data })
}

// 删除运单管理
export const deleteWaybill = async (id: string) => {
  return await request.delete({ url: `/queue/waybill/delete?waybillNo=` + id })
}

// 导出运单管理 Excel
export const exportWaybill = async (params) => {
  return await request.download({ url: `/queue/waybill/export-excel`, params })
}

//运单手动完成
export const finishWaybill = async (waybillNo: string) => {
  return await request.put({ url: `/queue/waybill/finish?waybillNo=${waybillNo}` })
}

// 获取运单定位信息
export const getWaybillGps = async (data) => {
  return await request.get({
    url: `/queue/waybill-gps/get?waybillNo=${data.waybillNo}&startTime=${data.startTime}&endTime=${data.endTime}`
  })
}
// 变更运单操作记录
export const changeWaybillRecord = async (data) => {
  return await request.get({
    url: `/queue/operate-recode/page?pageNo=${data.pageNo}&pageSize=${data.pageSize}&type=${data.type}&dataId=${data.dataId}`
  })
}
